package com.greenyoung.pwiki.oss.entity;


import org.springframework.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * 所有的返回结果都经此封装
 */
public class Result extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public Result() {
        put("code", 0);
        put("msg", "success");
    }

    public static com.greenyoung.pwiki.oss.entity.Result error() {
        return error(HttpStatus.INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static com.greenyoung.pwiki.oss.entity.Result error(String msg) {
        return error(HttpStatus.INTERNAL_SERVER_ERROR, msg);
    }

    public static com.greenyoung.pwiki.oss.entity.Result error(HttpStatus code, String msg) {
        com.greenyoung.pwiki.oss.entity.Result r = new com.greenyoung.pwiki.oss.entity.Result();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static com.greenyoung.pwiki.oss.entity.Result ok(String msg) {
        com.greenyoung.pwiki.oss.entity.Result r = new com.greenyoung.pwiki.oss.entity.Result();
        r.put("msg", msg);
        return r;
    }

    public static com.greenyoung.pwiki.oss.entity.Result ok(Map<String, Object> map) {
        com.greenyoung.pwiki.oss.entity.Result r = new com.greenyoung.pwiki.oss.entity.Result();
        r.putAll(map);
        return r;
    }

    public static com.greenyoung.pwiki.oss.entity.Result ok() {
        return new com.greenyoung.pwiki.oss.entity.Result();
    }

    public com.greenyoung.pwiki.oss.entity.Result put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
